package com.auth.manager.web.dict;

import com.auth.manager.common.resp.Result;
import com.auth.manager.pojo.dict.StandardCodeType;
import com.auth.manager.service.dict.StandardCodeTypeService;
import com.auth.manager.utils.page.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @version 1.0.0
 * @Date: 2022/5/12 16:53
 * @Author ZhuYouBin
 * @Description 标准代码分类
 */
@RestController
@RequestMapping("/standardCode/type")
public class StandardCodeTypeController {

    @Autowired
    private StandardCodeTypeService standardCodeTypeService;

    @PostMapping("/create")
    public Result create(@RequestBody @Valid StandardCodeType standardCodeType) {
        standardCodeTypeService.createCodeType(standardCodeType);
        return Result.success("新增成功");
    }

    @GetMapping("/delete/{id}")
    public Result remove(@PathVariable String id) {
        standardCodeTypeService.removeCodeType(id);
        return Result.success("删除成功");
    }

    @PostMapping("/update")
    public Result update(@RequestBody @Valid StandardCodeType standardCodeType) {
        standardCodeTypeService.updateCodeType(standardCodeType);
        return Result.success("更新成功");
    }

    @GetMapping("/queryPage")
    public Result queryPage(StandardCodeType standardCodeType, PageVo pageVo) {
        PageVo queryPage = standardCodeTypeService.queryPage(pageVo, standardCodeType);
        return Result.success("查询成功").setData(queryPage);
    }
}
